package com.efuture.servlet.request;

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

import java.io.BufferedReader;
import java.io.IOException;

/**
 * @description: 通过request获取请求体数据 针对post请求
 * @author zhaoshanshan
 * @date 2021/10/2 10:29 下午
 * @version 1.0
 */

@WebServlet("/GetRequestBody")
public class GetRequestBody extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        BufferedReader br = request.getReader();
        String line = null;
        while (null!=(line = br.readLine())){
            System.out.println(line);
        }
        if(br!=null){
            br.close();
            br = null;
        }

    }
}
